﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpTrainer.Util;
using Zeus.Thunder.Core;

namespace SharpTrainer.Delegates
{
    class SimpleLamda : ITestCase
    {
        public void Run()
        {
            int[] numbers = new[] { 1, 2, 3, 4, 5 };
            var evens1 = numbers.Where(delegate(int i) { return i % 2 == 0; });
            var odds1 = numbers.Where(delegate(int i) { return i % 2 != 0; });

            Console.WriteLine("Using Delegate:");
            Console.Write("Even: ");
            Display(evens1);
            Console.WriteLine();
            Console.Write("Odd: ");
            Display(odds1);
            Console.WriteLine();


            var evens2 = numbers.Where(i => i % 2 == 0);
            var odds2 = numbers.Where(i => i % 2 != 0);

            Console.WriteLine("Using Lamda:");
            Console.Write("Even: ");
            Display(evens2);
            Console.WriteLine();
            Console.Write("Odd: ");
            Display(odds2);
            Console.WriteLine();
        }

        private void Display(IEnumerable<int> lst)
        {
            GenericUtil<int>.PrintEnumerable(lst);
        }
    }
}
